using System;

namespace noug.tdd {
    public interface IUserValidator {
        bool IsValid(User user);
    }
    public class UserValidator : IUserValidator {
        private EmailValidator _validator;

        public UserValidator(EmailValidator validator) {
            _validator = validator;
        }

        public virtual bool IsValid(User user) {
            if (String.IsNullOrEmpty(user.Name)) return false;
            if (!_validator.IsValid(user.Email)) return false;
            if (user.Address == null) return false;
            return true;
        }

    }
}
